'''
今有物不知其数，三三数之剩二，五五数之剩三，七七数之剩二
'''
n=1
while True:
    if n%3==2 and n%5==3 and n%7==2:
        print(n)
        break
    else:
        n+=1
